package com.wancaijinfu.widget;

import com.wancaijinfu.actitvity.R;
import com.wancaijinfu.constant.MyApplication;
import com.wancaijinfu.network.MNetWork;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
/**
 * 
 * jichu
 * @author chenshikai@126.com
 * 
 * */
public abstract class BaseActivity extends FragmentActivity {
	private FrameLayout mContentView;
	private MActionBar mActionBar;
	
	
	protected String tag;
	public MyApplication application;
	private final View.OnClickListener leftListener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.base_activity);
		mActionBar = MActionBar.getInstance(findViewById(R.id.action_bar));
		mContentView = (FrameLayout) findViewById(R.id.activity_content);
		mActionBar.setActionBarLeft(leftListener);
	     application = (MyApplication) getApplication();
		//mActionBar.startTitleAnim();
		setMTitle(mActionBar);
		initView();
		afterView();
		initListener();
	}
	
	protected void initView() {};
	protected void afterView() {};
	protected void initListener() {};
	
	public void AddBaseContentView(View view) {
		mContentView.removeAllViews();
		mContentView.addView(view);
	}
	
	public void AddBaseContentViewNotRemove(View view) {
		mContentView.addView(view);
	}
	
	public void removeBaseContent() {
		mContentView.removeAllViews();
	}
	
	public ViewGroup getRootView() {
		return mContentView;
	}
	
	public MActionBar getMActionBar() {
		return mActionBar;
	}
	
	public abstract void setMTitle(MActionBar actionBar);
	
	@Override
	protected void onPause() {
	//	JPushInterface.onPause(this);
		super.onPause();
		MNetWork.getInstance(this).cancelRequest(tag);
	}
	@Override
	protected void onResume() {
	//	JPushInterface.onResume(this);
		// TODO Auto-generated method stub
		super.onResume();
	}
	
	
	
}
